package com.szxb.facebus.manager;

import com.szxb.facebus.db.manager.DBManager;
import com.szxb.facebus.db.sp.CommonSharedPreferences;
import com.szxb.facebus.db.sp.FetchAppConfig;
import com.szxb.facebus.util.basics.DateUtil;
import com.szxb.facebus.util.basics.Util;

/**
 * 作者：Tangren on 2018-12-07
 * 包名：com.szxb.facebus.manager
 * 邮箱：996489865@qq.com
 * TODO:一句话描述
 */

public class PosManager implements IPosManager {

    private String faceLisFileName;
    private String appID = "10000013";
    private String lineNo = "1234567890";
    private String city_code = "3333";
    //递增流水号
    private int numSeq = 0;

    private int isDownFinish;
    private String apk_info;

    @Override
    public void loadParams() {
        faceLisFileName = FetchAppConfig.getFaceListFileName();
        isDownFinish = FetchAppConfig.getDownFinish();
        apk_info = FetchAppConfig.getAPKInfo();
        numSeq = Integer.valueOf(FetchAppConfig.getNumSeq());
    }

    @Override
    public String getFaceListFileName() {
        return faceLisFileName;
    }

    @Override
    public void setFaceListFileName(String fileName) {
        this.faceLisFileName = fileName;
        CommonSharedPreferences.put("face_list_file_name", fileName);
    }

    @Override
    public String getAppId() {
        return appID;
    }

    @Override
    public void setAppId(String app_id) {

    }

    @Override
    public String getCityCode() {
        return city_code;
    }

    @Override
    public void setCityCode() {

    }

    @Override
    public String getLienNo() {
        return lineNo;
    }

    @Override
    public void setLienNo(String lineNo) {

    }


    @Override
    public int isDownFinish() {
        return isDownFinish;
    }

    @Override
    public void setDownFinish(int flag) {
        this.isDownFinish = flag;
        CommonSharedPreferences.put("down_finish", flag);
    }

    @Override
    public String getAPKInfo() {
        return apk_info;
    }

    @Override
    public void setAPKInfo(String name) {
        this.apk_info = name;
        CommonSharedPreferences.put("apk_info", name);
    }

    @Override
    public String getmchTrxId() {
        if (numSeq >= 99999999) {
            numSeq = 0;
        }
        numSeq++;
        String numSeqStr = Util.getNumSeq(numSeq);
        CommonSharedPreferences.put("num_seq", numSeqStr);

        return Util.Random(10) + numSeqStr;
    }

    @Override
    public String getLineName() {
        return "测试线路";
    }

    @Override
    public void setLineName(String var1) {

    }

    @Override
    public String getLineNo() {
        return "00";
    }

    @Override
    public void setLineNo(String var1) {

    }

    @Override
    public String getMac(String keyId) {
        return DBManager.getMac(keyId);
    }

    @Override
    public String getPublicKey(String keyId) {
        return DBManager.getPublicKey(keyId);
    }

    @Override
    public long getOrderTime() {
        return DateUtil.currentLong();
    }

    @Override
    public int getBasePrice() {
        return 1;
    }

    @Override
    public void setBasePrice(int var1) {

    }

    @Override
    public int getWcPayPrice() {
        return 1;
    }

    @Override
    public void setWcPrice(int var1) {

    }

    @Override
    public String getPosSN() {
        return "1234567890";
    }
}
